//Design By Do Trung --- Email : trungqn19852003@yahoo.com
//Ngày Design :09/12/2011 4:57:03 PM
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using VietStar.Library.Commom.SqlServer;
using Entity = VietStar.Library.Entity;
namespace VietStar.Library.Data
{
    /// <summary>
    /// </summary>
    public class LoaiSanPham
    {
        public LoaiSanPham() { }
        Connection db = new Connection();

        /// <summary>
        /// Inserts a record into the DanhMucSanPham table.
        /// <summary>
        /// <param name="Id"></param>
        /// <param name="Ten"></param>
        /// <param name="DanhMucCha"></param>
        /// <param name="TrangThai"></param>
        /// <returns></returns>


        /// <summary>
        /// Selects a single record from the DanhMucSanPham table.
        /// <summary>
        /// <returns>DataTable</returns>
        public DataTable Select()
        {
            DataTable dt = new DataTable();
            SqlConnection SqlCnn = db.ReadFromWebConfig();
            SqlDataAdapter SqlAdp = new SqlDataAdapter();
            SqlCommand SqlCmd = new SqlCommand();
            SqlTransaction SqlTrans = SqlCnn.BeginTransaction();
            try
            {
                SqlCmd.Transaction = SqlTrans;
                SqlCmd.Connection = SqlCnn;
                SqlCmd.CommandText = "Proc_LoaiSanPham_Select";
                SqlCmd.CommandType = CommandType.StoredProcedure;
                SqlAdp.SelectCommand = SqlCmd;
                SqlAdp.SelectCommand.ExecuteNonQuery();
                SqlAdp.Fill(dt);
                SqlCmd.Transaction.Commit();
                SqlCnn.Close();
            }
            catch
            {
                SqlCmd.Transaction.Rollback();
            }
            finally
            {
                SqlCmd.Parameters.Clear();
                SqlTrans = null;
            }
            if (SqlCmd != null)
                SqlCmd.Dispose();
            if (SqlAdp != null)
                SqlAdp.Dispose();
            return dt;
        }

        /// <summary>
        /// Selects a single record from the DanhMucSanPham table.
        /// <summary>
        /// <returns>DataTable</returns>

    }
}
